{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 文件data  CRD接口测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "import base64\n",
    "\n",
    "\n",
    "# 参数\n",
    "DeviceID = \"01234567895041231456\"\n",
    "User = \"zhou1\"\n",
    "Passwd = \"123\"\n",
    "host = \"192.168.2.97:5656\"\n",
    "ID = \"01234567895041231456032018010211500000001\"\n",
    "imgPath = \"/home/zhou/img/1.jpg\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### C 创建图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'ResponseStatusObject': {'Id': '01234567895041231456032018010211500000001',\n",
       "  'LocalTime': '20180109174827',\n",
       "  'RequestURL': '/VIID/Files/01234567895041231456032018010211500000001/Data',\n",
       "  'StatusCode': '0',\n",
       "  'StatusString': 'add fileInfoData success'}}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "with open(imgPath, 'rb') as f:\n",
    "    img = base64.b64encode(f.read())\n",
    "    \n",
    "re = requests.post(url='http://%s/VIID/Files/%s/Data' % (host, ID), headers={'User-Identify': DeviceID}, data=img)\n",
    "re.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### R 查询图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/9j/4iFSSEtKSZEdYAxEHQAAbAgAADQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPlwAACgAIAxYBDwAA'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re = requests.get(url='http://%s/VIID/Files/%s/Data' % (host, ID), headers={'User-Identify': DeviceID})\n",
    "re.text[:100]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### D 删除图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'ResponseStatusObject': {'Id': '01234567895041231456032018010211500000001',\n",
       "  'LocalTime': '20180109174835',\n",
       "  'RequestURL': '/VIID/Files/01234567895041231456032018010211500000001/Data',\n",
       "  'StatusCode': '0',\n",
       "  'StatusString': 'remove fileInfoData success'}}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re = requests.delete(url='http://%s/VIID/Files/%s/Data' % (host, ID), headers={\"User-Identify\": DeviceID})\n",
    "re.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 图像data  CRD接口测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 参数\n",
    "ID = \"01234567895041231456022018010211500000001\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### C 创建图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'ResponseStatusObject': {'Id': '01234567895041231456022018010211500000001',\n",
       "  'LocalTime': '20180109091048',\n",
       "  'RequestURL': '/VIID/Images/01234567895041231456022018010211500000001/Data',\n",
       "  'StatusCode': '4',\n",
       "  'StatusString': 'id[01234567895041231456022018010211500000001] objectInfo not found'}}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "with open(imgPath, 'rb') as f:\n",
    "    img = base64.b64encode(f.read())\n",
    "    \n",
    "re = requests.post(url='http://%s/VIID/Images/%s/Data' % (host, ID), headers={'User-Identify': DeviceID}, data=img)\n",
    "re.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### R 查询图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/9j/4iFSSEtKSZEdYAxEHQAAbAgAADQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPlwAACgAIAxYBDwAA'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re = requests.get(url='http://%s/VIID/Images/%s/Data' % (host, ID), headers={'User-Identify': DeviceID})\n",
    "re.text[:100]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### D 删除图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'ResponseStatusObject': {'Id': '01234567895041231456022018010211500000001',\n",
       "  'LocalTime': '20180105180942',\n",
       "  'RequestURL': '/VIID/Images/01234567895041231456022018010211500000001/Data',\n",
       "  'StatusCode': '0',\n",
       "  'StatusString': 'remove imageInfoData success'}}"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re = requests.delete(url='http://%s/VIID/Images/%s/Data' % (host, ID), headers={\"User-Identify\": DeviceID})\n",
    "re.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 视频data CRD接口测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "#参数\n",
    "ID = \"01234567895041231456012018010211500000001\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### C 创建图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'ResponseStatusObject': {'Id': '01234567895041231456012018010211500000001',\n",
       "  'LocalTime': '20180105161715',\n",
       "  'RequestURL': '/VIID/VideoSlices/01234567895041231456012018010211500000001/Data',\n",
       "  'StatusCode': '0',\n",
       "  'StatusString': 'add videoSliceInfoData success'}}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "with open(imgPath, 'rb') as f:\n",
    "    img = base64.b64encode(f.read())\n",
    "    \n",
    "re = requests.post(url='http://%s/VIID/VideoSlices/%s/Data' % (host, ID), headers={'User-Identify': DeviceID}, data=img)\n",
    "re.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### R 查询图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/9j/4iFSSEtKSZEdYAxEHQAAbAgAADQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPlwAACgAIAxYBDwAA'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re = requests.get(url='http://%s/VIID/VideoSlices/%s/Data' % (host, ID), headers={'User-Identify': DeviceID})\n",
    "re.text[:100]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### D 删除图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'ResponseStatusObject': {'Id': '01234567895041231456012018010211500000001',\n",
       "  'LocalTime': '20180105161854',\n",
       "  'RequestURL': '/VIID/VideoSlices/01234567895041231456012018010211500000001/Data',\n",
       "  'StatusCode': '0',\n",
       "  'StatusString': 'remove videoSliceInfoData success'}}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re = requests.delete(url='http://%s/VIID/VideoSlices/%s/Data' % (host, ID), headers={\"User-Identify\": DeviceID})\n",
    "re.json()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
